//
//  Engine.h
//  CompGraf2
//
//  Created by Juan Niosi on 09/08/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>

#import <OpenGLES/EAGL.h>

#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>

#import "EAGLView.h"
#import "Texture.h"

@class Entity;

@interface Engine : NSObject
{
    EAGLView *eaglView;
    int lightCount;
    NSDate *startDate;
    float lastUpdateTime;
    float lastUpdateDelta;
    GLint *viewport;
}
@property (nonatomic, retain) EAGLView *eaglView;
@property (nonatomic) float lastUpdateTime;
@property (nonatomic) float lastUpdateDelta;
@property (nonatomic) GLint *viewport;

- (id)initWithView:(UIView *)oglView;
- (void)clear;
- (void)update;
- (void)drawGeometry:(GLfloat *)verts vertCount:(GLint)count;
- (void)drawGeometry:(GLfloat *)verts vertCount:(GLint)count withColor:(GLfloat *)colors;
- (void)drawGeometry:(GLfloat *)verts vertCount:(GLint)count withTexture:(Texture *)texture setUVs:(GLfloat *)uvs setNormals:(GLfloat *)normals;
- (void)drawGeometry:(GLfloat *)verts vertCount:(GLint)count withColor:(GLfloat *)colors withTexture:(Texture *)texture setUVs:(GLfloat *)uvs setNormals:(GLfloat *)normals;
- (void)set_transform;
- (void)reset_transform;
- (Texture *)load_texture:(NSString *)filename;

- (void)drawBox:(GLfloat)xMin:(GLfloat)xMax:(GLfloat)yMin:(GLfloat)yMax:(GLfloat)zMin:(GLfloat)zMax;

- (void)translate:(GLfloat *)pos;
- (void)rotate:(GLfloat *)rotation;
- (void)scale:(GLfloat *)scale;

- (void)translateX:(GLfloat)dist;
- (void)translateY:(GLfloat)dist;
- (void)translateZ:(GLfloat)dist;

- (void)drawLight:(GLenum)glenum setPos:(GLfloat *)pos setAmbient:(GLfloat *)amb setDiffuse:(GLfloat *)dif setSpecular:(GLfloat *)spec setAttenuation:(GLfloat)attenuation;
- (void)drawSpotLight:(GLenum)glenum setPos:(GLfloat *)pos setAmbient:(GLfloat *)amb setDiffuse:(GLfloat *)dif setSpecular:(GLfloat *)spec setAttenuation:(GLfloat)attenuation setAngle:(GLfloat)angle setDir:(GLfloat *)direction setExponent:(GLfloat)exp;

- (void)drawLine:(GLfloat *)init:(GLfloat *)end;
- (void)updateViewport:(UIInterfaceOrientation)orientation;
@end
